/*
 * Copyright (C) 2013 Daniel Treffenstädt <daniel@treffenstaedt.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#include "OPath.h"

O_START_NAMESPACE

Path::Path()
{
	m_start		= Position(0, 0);
	m_close		= true;
}

Path::Path(Position start, bool close)
{
	m_start		= start;
	m_close		= close;
}

void Path::moveTo(Position p)
{
	m_start		= p;
}

void Path::close(bool state)
{
	m_close		= state;
}

void Path::addPoint(PathPoint p)
{
	m_points.append(p);
}

void Path::addPoint(Position p)
{
	addPoint(PathPoint(p));
}

void Path::addPoint(Position p, Degree deg)
{
	addPoint(PathPoint(p, deg));
}

void Path::addPoint(Position p, Position p1, Position p2)
{
	addPoint(PathPoint(p, p1, p2));
}

int Path::points()
{
	return m_points.length();
}

PathPoint Path::point(int index)
{
	if (index >= points() || index < 0)
	{
		return PathPoint();
	}
	return m_points[index];
}

void Path::operator =(Path p)
{
	m_start		= p.m_start;
	m_close		= p.m_close;

	for (int i = 0; i < p.points(); i++)
	{
		addPoint(p.point(i));
	}
}

O_END_NAMESPACE
